/*import java.util.Arrays;
public class Test {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4};
        //分别调用func1和func2之后，arr数组里面的值分别是多少？
        func2(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void func1(int[] array){
        array[0] = 99;
    }
    public static void func2(int[] array){
        array = new int[]{11,22,33,44,55};
    }
}*/
/*
import java.util.Arrays;

public class Test {

    public static void bubbleSort(int[] array) {
        //i 代表排序的趟数
        for (int i = 0; i < array.length - 1; i++) {
            boolean flag = true;//优化
            for (int j = 0; j < array.length - i - 1; j++) {
                if (array[j] > array[j + 1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j+1]=tmp;
                    flag = false;
                }
            }
            if(flag){
                break;
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = {31, 23, 3, 24, 15, 63, 47};
        bubbleSort(arr);
        System.out.println(myToString(arr));
    }

    public static String myToString(int[] array) {
        if (array == null) {
            return "null";
        }
        if (array.length == 0) {
            return "[]";
        }
        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];
            if (i < array.length - 1) {
                ret += ", ";
            }
        }
        ret += "]";
        return ret;
    }

    public static int[] func() {

        int[] arr = new int[]{21, 12, 32, 14, 5};

        System.out.println(Arrays.toString(arr));

        return arr;
    }

    public static void main1(String[] args) {

        int[] arr = new int[]{21, 12, 32, 14, 5};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

    }
}*/
/*
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {

        int[][] array = new int[2][];
        //array[0] = {1,2};
        //array[1] = {3,4,5}; //程序报错

        *//*array[0] = new int[]{1,2};
        array[1] = new int[]{1,2,3,4};*//*

    }
    public static void main1(String[] args) {

        int[][] array = new int[][]{{1,2,3},{4,5,6}};
        for(int[] arr:array){
            for(int x:arr){
                System.out.print(x+" ");
            }
            System.out.println();
        }


        String ret = Arrays.deepToString(array);
        System.out.println(ret);

        *//*for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }*//*

    }

    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5};
        int[] copy = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            copy[i] = array[i];
        }
        System.out.println(Arrays.toString(copy));
    }
}*/
/*

public class Test {
    public static int add(int x, int y) {
        return x + y;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int ret = add(3, 5);
        System.out.println(ret);
    }
}
*/

/*
public class Test {
    //求n的阶乘
    public static int fac(int n) {
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }
    //求阶乘和
    public static int facSum(int k){
        int sum = 0;
        for (int i = 1; i <= k; i++) {
            sum+=fac(i);
        }
        return sum;
    }
    public static void main(String[] args) {
        int ret = facSum(5);
        System.out.println(ret);
    }
    public static int add(int a, int b){
        return a + b;
    }
    //add(2, 3); // 2和3是实参，在调用时传给形参a和b
}*/
/*
public class Test {
    public static void print(int n) {
        if (n >= 10) {
            print(n / 10);
        }
        System.out.print(n % 10 + " ");
    }
    public static void main(String[] args) {
        print(1234567);
    }
}*/

/*
public class Test {
    public static int sum(int n) {
        if(n==1){
            return 1;
        }
        return n + sum(n-1);
    }
    public static void main(String[] args) {
        int ret = sum(10);
        System.out.println(ret);
    }
}*/

public class Test {
    public static int add(int n) {
        if (n < 10) {
            return n;
        }
        return n % 10 + add(n / 10);
    }
    public static void main(String[] args) {
        int ret = add(12345);
        System.out.println(ret);
    }
}









